#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 2000001
#define inf 0x1fffffff
int n, m;
int minum[maxn];
int arr[maxn];
int main()
{
    cin >> n >> m;
    for (int i = 1, minumber = inf, tmp; i <= n; ++i)
    {
        scanf("%d", &arr[i]);
        if (i <= m)
        {
            if (minumber > arr[i])
                minumber = arr[i];
            minum[i] = minumber;
        }
        else
        {
            if (arr[i] < arr[i - m])
            {
                minum[i] = min(minum[i - 1], arr[i]);
            }
            else
            {
                if (arr[i - m] == minum[i - 1])
                {
                    minumber = inf;
                    for (int j = i - m + 1; j <= i; ++j)
                    {
                        if (arr[j] < minumber)
                            minumber = arr[j];
                    }
                    minum[i] = minumber;
                }
                else
                {
                    minum[i] = min(minum[i - 1], arr[i]);
                }
            }
        }
    }
    for (int i = 0; i < n; ++i)
        printf("%d\n", minum[i]);
    return 0;
}